package com.hk.controller.admin;

import com.hk.model.pojo.SysDictData;
import com.hk.result.PageResult;
import com.hk.result.Result;
import com.hk.service.DictDataService;
import com.hk.service.DictTypeService;
import lombok.extern.slf4j.Slf4j;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("system/dict/data")
@Api(tags = "字典数据管理")
public class DictDataController {

    @Autowired
    private DictDataService dictDataService;


    @ApiOperation("查询性别字典数据")
    @GetMapping("/type/sys_user_sex")
    public Result<List<SysDictData>> getSex() {
        List<SysDictData> list = dictDataService.getSex();
        return Result.success(list);
    }

    @ApiOperation("回收时限字典数据")
    @GetMapping("/type/limit_time")
    public Result<List<SysDictData>> getLimitTime() {
        List<SysDictData> list = dictDataService.getLimitTime();
        return Result.success(list);
    }

    @ApiOperation("回收到期提醒定时字典数据")
    @GetMapping("/type/warn_time")
    public Result<List<SysDictData>> getWarnTime() {
        List<SysDictData> list = dictDataService.getWarnTime();
        return Result.success(list);
    }

    @ApiOperation("查询重复捞取时间限制字典数据")
    @GetMapping("/type/repeat_get_time")
    public Result<List<SysDictData>> getRecycleTime() {
        List<SysDictData> list = dictDataService.getRecycleTime();
        return Result.success(list);
    }

    @ApiOperation("查询跟进状态字典数据")
    @GetMapping("/type/clue_status")
    public Result<List<SysDictData>> getFollowStatus() {
        List<SysDictData> list = dictDataService.getFollowStatus();
        return Result.success(list);
    }

    @ApiOperation("查询意向等级字典数据")
    @GetMapping("/type/clues_level")
    public Result<List<SysDictData>> getCluesLevel() {
        List<SysDictData> list = dictDataService.getCluesLevel();
        return Result.success(list);
    }

    @ApiOperation("查询课程字典数据")
    @GetMapping("/type/course_subject")
    public Result<List<SysDictData>> getCourseSubject() {
        List<SysDictData> list = dictDataService.getCourseSubject();
        return Result.success(list);
    }

    @ApiOperation("查询适用人群字典数据")
    @GetMapping("/type/applicable_person")
    public Result<List<SysDictData>> getApplicablePerson() {
        List<SysDictData> list = dictDataService.getApplicablePerson();
        return Result.success(list);
    }

    @ApiOperation("查询渠道来源字典数据")
    @GetMapping("/type/channel_type")
    public Result getChannelList() {
        List<SysDictData> list = dictDataService.getChannelList();

        return Result.success(list);
    }

    @ApiOperation("查询活动类型字典数据")
    @GetMapping("/type/clues_item")
    public Result getCluesItem() {
        List<SysDictData> list = dictDataService.getCluesItem();

        return Result.success(list);
    }

    @ApiOperation("查询活动状态字典数据")
    @GetMapping("/type/activity_status")
    public Result getActivityStatus() {
        List<SysDictData> list = dictDataService.getActivityStatus();
        log.info("获取到的{}", list);
        return Result.success(list);
    }

    @ApiOperation("字典状态")
    @GetMapping("/type/sys_normal_disable")
    public Result<List<SysDictData>> getNormalDisable() {
        List<SysDictData> list = dictDataService.getNormalDisable();
        return Result.success(list);
    }

    @ApiOperation("新增字典数据")
    @PostMapping
    public Result<String> addDictData(@RequestBody SysDictData sysDictData) {
        dictDataService.addDictData(sysDictData);
        return Result.success();
    }

    @ApiOperation("分页查询查询字典数据")
    @GetMapping("/list")
    public PageResult selectDictDataByPage(Integer pageNum, Integer pageSize, String dictName, String dictType, Integer status, String beginTime, String endTime) {
        return dictDataService.selectDictDataByPage(pageNum, pageSize, dictName, dictType, status, beginTime, endTime);
    }

    @ApiOperation("根据id查询")
    @GetMapping("/{dictId}")
    public Result<SysDictData> getDictDataById(@PathVariable Long dictId) {
        SysDictData sysDictData = dictDataService.getDictDataById(dictId);
        return Result.success(sysDictData);
    }

    @ApiOperation("修改字典数据")
    @PutMapping
    public Result<String> updateDictData(@RequestBody SysDictData sysDictData) {

        dictDataService.updateDictData(sysDictData);
        return Result.success();
    }

    @ApiOperation("批量删除字典数据")
    @DeleteMapping("/{ids}")
    public Result<String> deleteDictData(@PathVariable Long[] ids) {
        dictDataService.deleteDictData(ids);
        return Result.success();
    }
}
